import { Component, ViewEncapsulation } from '@angular/core';

@Component({
  selector: 'app-preset-date-range',
  templateUrl: './preset-date-range.component.html',
  styles: [``],
  encapsulation: ViewEncapsulation.None,
})
export class PresetDateRangeComponent {
  rangeDate1: Date[];
  rangeDate2: Date[];
  ranges = [
    { 'Next 7 days': [new Date(), new Date(new Date().getTime() + 3600 * 1000 * 24 * 7)] },
    { 'This Month': [this.getTimeArea().firstDate, this.getTimeArea().endDate] },
  ];

  getTimeArea() {
    const date = new Date();
    const firstDate = date.setDate(1);
    let endDate = new Date(firstDate);
    endDate.setMonth(date.getMonth() + 1);
    endDate.setDate(0);

    return { firstDate, endDate };
  }
}
